﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using HtmlAgilityPack;
using System.Collections.Generic;

namespace RssReaderTemplate.Model.TagProcessors
{
    public class StrongProcessor : TagProcessor
    {
        public StrongProcessor() : base("strong")
        {

        }
        public override ContentFragment PreProcessTag(HtmlNode node, IDictionary<string, object> processingContext)
        {
            object isBold;
            if (processingContext.TryGetValue("IsBold", out isBold))
            {
                isBold = ((int)isBold) + 1;
                processingContext.Remove("IsBold");
                processingContext.Add("IsBold", isBold);
            }
            else
            {
                processingContext.Add("IsBold", 1);
            }
            return null;
        }

        public override ContentFragment PostProcessTag(HtmlNode node, IDictionary<string, object> processingContext)
        {
            object isBold;
            if (processingContext.TryGetValue("IsBold", out isBold))
            {
                isBold = ((int)isBold) - 1;
                processingContext.Remove("IsBold");
                processingContext.Add("IsBold", isBold);
            }
            return null;
        }
    }
}
